﻿using Domain.Entities;
using Domain.Entities.HealthManages;
using FluentMigrator;
using FrameworkCore.Extensions;

namespace AiBLSmartEdu.Module.AIHealthManage.API.Migrations;

[Migration(202506181053)]
public class HealthRecordAddColumn : ForwardOnlyMigration
{
    public override void Up()
    {
        Alter.Table(MigrationExpressions.GetTableName(typeof(HealthRecord)))
          .AddColumn(MigrationExpressions.ColumnNameFor<HealthRecord>(nameof(HealthRecord.CustomerId))).AsInt64().Nullable().WithColumnDescription("关联用户")
          .AddColumn(MigrationExpressions.ColumnNameFor<HealthRecord>(nameof(HealthRecord.Gender))).AsString(4).Nullable().WithColumnDescription("性别")
          .AddColumn(MigrationExpressions.ColumnNameFor<HealthRecord>(nameof(HealthRecord.Birthday))).AsDateTime().Nullable().WithColumnDescription("出生年月")
          .AddColumn(MigrationExpressions.ColumnNameFor<HealthRecord>(nameof(HealthRecord.Height))).AsDecimal(5,2).Nullable().WithColumnDescription("身高（单位：厘米，可选）")
          .AddColumn(MigrationExpressions.ColumnNameFor<HealthRecord>(nameof(HealthRecord.Weight))).AsDecimal(5,2).Nullable().WithColumnDescription("体重（单位：千克，可选）")
          .AddColumn(MigrationExpressions.ColumnNameFor<HealthRecord>(nameof(HealthRecord.BloodType))).AsString(10).Nullable().WithColumnDescription("血型（示例：A型/B型/AB型/O型）")
          .AddColumn(MigrationExpressions.ColumnNameFor<HealthRecord>(nameof(HealthRecord.BloodPressure))).AsString(20).Nullable().WithColumnDescription("血压（存储格式示例：120/80）")
          .AddColumn(MigrationExpressions.ColumnNameFor<HealthRecord>(nameof(HealthRecord.HeartRate))).AsInt32().Nullable().WithColumnDescription("心率（单位：次/分钟，可选）")
          .AddColumn(MigrationExpressions.ColumnNameFor<HealthRecord>(nameof(HealthRecord.FastingBloodGlucose))).AsDecimal(4,2).Nullable().WithColumnDescription("空腹血糖（单位：mmol/L，空腹8小时以上）")
          .AddColumn(MigrationExpressions.ColumnNameFor<HealthRecord>(nameof(HealthRecord.PostprandialBloodGlucose))).AsDecimal(4,2).Nullable().WithColumnDescription("餐后血糖（单位：mmol/L，餐后2小时测量）")
          .AddColumn(MigrationExpressions.ColumnNameFor<HealthRecord>(nameof(HealthRecord.RandomBloodGlucose))).AsDecimal(4, 2).Nullable().WithColumnDescription("随机血糖（单位：mmol/L，任意时间测量）")
          .AddColumn(MigrationExpressions.ColumnNameFor<HealthRecord>(nameof(HealthRecord.GlycatedHemoglobin))).AsDecimal(4, 2).Nullable().WithColumnDescription("糖化血红蛋白（HbA1c，单位：%，反映近3个月血糖平均水平）")
          .AddColumn(MigrationExpressions.ColumnNameFor<HealthRecord>(nameof(HealthRecord.GlucoseTrend))).AsInt32().Nullable().WithColumnDescription("血糖趋势标识（0: 平稳，1: 上升，2: 下降）")
          .AddColumn(MigrationExpressions.ColumnNameFor<HealthRecord>(nameof(HealthRecord.Result))).AsString(int.MaxValue).Nullable().WithColumnDescription("结果");
    }
}